//
//  RMMXiuGaiOrderView.m
//  Romomo
//
//  Created by puman on 2016/11/17.
//  Copyright © 2016年 mazegong. All rights reserved.
//

#import "RMMXiuGaiOrderView.h"
@implementation RMMXiuGaiOrderView
{
    NSArray *_array;
}

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _backView = [[UIView alloc] initWithFrame:self.bounds];
        _backView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        _backView.alpha = 0.0;
        [self addSubview:_backView];
        
        UIButton *button = [UIButton buttonWithType:(UIButtonTypeCustom)];
        button.frame = CGRectMake(0, 0, self.width, self.height - 188);
        BUTTON_S(button, cancelBut);
        [_backView addSubview:button];
        
        _view = [[UIView alloc] initWithFrame:CGRectMake(0, self.height, self.width, 188)];
        _view.backgroundColor = kCColor;
        [self addSubview:_view];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _view.width, 29)];
        label.text = @"注意每笔订单只能修改一次";
        label.textColor = kBasicColor;
        label.font = kFont(12);
        label.backgroundColor = kWhiteColor;
        label.textAlignment = NSTextAlignmentCenter;
        [_view addSubview:label];
        _array = @[@"修改时间",@"修改技师",@"取消"];
        for (int i = 0; i < 3; i++) {
            UIButton *buttons = [UIButton buttonWithType:(UIButtonTypeCustom)];
            buttons.backgroundColor = kWhiteColor;
            [buttons setTitle:_array[i] forState:(UIControlStateNormal)];
            BUTTON_S(buttons, buttonCkick:);
            buttons.titleLabel.font = kFont(16);
            if (i < 2) {
                buttons.frame = CGRectMake(0,30 + kHalf * i, _view.width, 49);
                [buttons setTitleColor:COLORFROMCODE(0x2C2C2C, 1) forState:(UIControlStateNormal)];
                switch (i) {
                    case 0:
                        _jiShiBut = buttons;
                        break;
                    case 1:
                        _dateBut = buttons;
                        break;

                    default:
                        break;
                }
            } else {
                buttons.frame = CGRectMake(0, _view.height - 49, _view.width, 49);
                [buttons setTitleColor:COLORFROMCODE(0x9B9B9B, 1) forState:(UIControlStateNormal)];
                BUTTON_S(buttons, cancelBut);
            }
            [_view addSubview:buttons];
        }
        
    }
    return self;
}
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    [super touchesBegan:touches withEvent:event];
//    if ([_tableViewTouchDelegate conformsToProtocol:@protocol(TableViewTouchDelegate)] && [_tableViewTouchDelegate respondsToSelector:@selector(tableView:touchesBegan:withEvent:)]) {
//        [_tableViewTouchDelegate tableView:self touchesBegan:touches withEvent:event];
//    }
//}

- (void)buttonCkick:(UIButton *)button{
    int count = 0;
    for (int i = 0; i < _array.count; i++) {
        NSString *string = _array[i];
        if ([string isEqualToString:[button titleForState:(UIControlStateNormal)]]) {
            count = i;
        }
    }
    if ([_xiuGaiOrderDelegate respondsToSelector:@selector(touchButCount:)]) {
        [_xiuGaiOrderDelegate touchButCount:count];
    }
}
- (void)cancelBut{
    [UIView animateWithDuration:kInterval animations:^{
        _backView.alpha = 0.0;
        _view.frame = CGRectMake(0, self.height, _view.width, 188);
    } completion:^(BOOL finished) {
        self.hidden = YES;
    }];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
